home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
bc_ti
/
ti711.asc
< prev
next >
Wrap
Text File
|
1992-02-24
|
2KB
|
133 lines
PRODUCT : Borland C++ NUMBER : 711
VERSION : 2.0
OS : DOS
DATE : February 25, 1992 PAGE : 1/2
TITLE : Disabling CTRL-BREAK and CTRL-C
/**********************************************************
The following code shows how to disable CTRL-BREAK and
CTRL-C.
************************************************************/
#include <conio.h>
#include <dos.h>
#include <stdlib.h>
char far *modifiers = MK_FP(0,0x417); /* address of modifier
flags */
void interrupt (*oldint9) (void); /* storage for old INT 9
handler */
void interrupt myint9(void)
{
/* ((*modifiers)&4)==4 indicates the CTRL key is being pressed
inportb(0x60)==46 indicates the C key is being pressed
inportb(0x60)==70 indicates the SCROLL LOCK/BREAK key "
The emit code is required to clean the keypress up from
the BIOS.
*/
if( (((*modifiers)&4)==4) &&
((inportb(0x60)==46) || (inportb(0x60)==70)) )
__emit__(0xe4,0x61, /* asm IN AL,61 */
0x8a,0xe0, /* asm MOV AH,AL */
0x0c,0x80, /* asm OR AL,80 */
0xe6,0x61, /* asm OUT 61,AL */
0x86,0xe0, /* asm XCHG AL,AH */
0xe6,0x61, /* asm OUT 61,AL */
0xb0,0x20, /* asm MOV AL,20 */
0xe6,0x20); /* asm OUT 20,AL */
else
/* If the key is not CTRL-C or CTRL-BREAK, call the old INT 9
handler */
oldint9();
PRODUCT : Borland C++ NUMBER : 711
VERSION : 2.0
OS : DOS
DATE : February 25, 1992 PAGE : 2/2
TITLE : Disabling CTRL-BREAK and CTRL-C
}
void exitfunc(void)
{
/* Restore the old INT 9 handler */
setvect(9,oldint9);
}
main()
{
int i;
oldint9=getvect(9); /* store old interrupt vector */
setvect(9,myint9); /* set up new interrupt handler */
atexit(exitfunc); /* set up exit handler to restore INT 9*/
/* ... */ /* code that will not CTRL-BREAK or CTRL-C */
return 0;
}